package main

import "fmt"

func gotoDemo() {
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			if j == 2 {
				goto breakTag
			}
			fmt.Printf("%v-%v\n", i, j)
		}
	}
	return
	breakTag:
		fmt.Println("结束for循环")
}
func switchDemo()  {
	a := "a"
	switch {
	case a == "a":
		fmt.Println(a)
		fallthrough		//可以执行满足条件的case的下一个case
	case a == "b":
		fmt.Println(a)
	}
}

func breakDemo() {
	BreakDemo:
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			if j == 2 {
				break BreakDemo
			}
			fmt.Printf("%v-%v\n", i, j)
		}
	}
	fmt.Println("...")
}

func continueDemo()  {
	ContinueDemo:
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			if j == 2 {
				continue ContinueDemo
			}
			fmt.Printf("%v-%v\n", i, j)
		}
	}
}
func main() {
	switchDemo()
	gotoDemo()
	breakDemo()
	continueDemo()
}
